package com.zshy.base.i18n.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.web.servlet.LocaleResolver;

/**
 * 国际化配置
 *
 * @author zhouhengzhe
 */
@Slf4j
@Configuration
public class I18nConfig {

    @Bean
    public LocaleResolver localeResolver() {
        return new I18nLocaleResolver();
    }



    /**
     * 系统国际化文件配置
     * @return MessageSource
     */
    @Bean
    public MessageSource messageSource() {
        ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
        log.info("如需国际化，请把国际化文件放到classpath:i18n/messages目录下");
        messageSource.setBasename("classpath:i18n/messages");
        return messageSource;
    }
}
